use apikit_core::error::ApiErrorItem;
use serde::{Deserialize, Serialize};

use crate::ty::ApiTypeId;

#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ApiRequest {
    pub parts: Vec<ApiParamPart>,

    pub content_type: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum ApiParamPart {
    Path {
        params: ApiTypeId,
        errors: Vec<ApiErrorItem>,
    },
    Query {
        params: ApiTypeId,
        errors: Vec<ApiErrorItem>,
    },
    Header {
        params: ApiTypeId,
        errors: Vec<ApiErrorItem>,
    },
    Body {
        params: ApiTypeId,
        errors: Vec<ApiErrorItem>,
    },
    WsHandler {
        send: ApiWebsocketMessage,
        receive: ApiWebsocketMessage,
        errors: Vec<ApiErrorItem>,
    },
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ApiWebsocketMessage {
    pub message: Option<ApiTypeId>,
    pub content_type: Option<String>,
}
